package com.community.process._1010.dao.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.community.process._1010.common.base.BaseEntity;
import com.community.process._1010.common.enums.OrderStatusEnum;
import com.community.process._1010.domains.ProcessOrderDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 到餐加工子订单
 *
 * @author Zbs
 * @since 2024-09-05
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@TableName("yg_process_order")
@Schema(description = "到餐加工子订单")
public class ProcessOrder extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @Schema(description = "TID")
    private Long tId;

    @Schema(description = "订单状态：	    1-待确认/待支付，	    2-已支付，	    3-已发货，	    4-超时未支付，	    5-已收货，	    6-已完结/确认收货，	    7-申请退款中，	    8-发货前退款完结，	    9-发货后退款完结，	    10-收货后退款完结，	    11-退款完结，	    12-买家关闭订单，	    13-商家关闭订单")
    private Integer orderStatus;

    @Schema(description = "买家ID")
    private Long userId;

    @Schema(description = "卖家ID")
    private Long sellerId;

    @Schema(description = "订单类型：1 食材单 2 成品菜订单")
    private Integer orderType;

    @Schema(description = "商品名称")
    private String itemName;

    @Schema(description = "商品图片")
    private String itemImage;

    @Schema(description = "支付金额")
    private Long payAmount;

    @Schema(description = "手机号")
    private String phone;

    @Schema(description = "联系人")
    private String contactPerson;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "地区ID")
    private Long areaId;

    @Schema(description = "地区名称")
    private String areaName;

    @Schema(description = "市ID")
    private Long cityId;

    @Schema(description = "就餐时间")
    private String dinnerTime;

    @Schema(description = "店铺名称")
    private String shopName;

    @Schema(description = "店铺地址")
    private String detailedAddress;

    @Schema(description = "店铺id")
    private Long shopId;

    @Schema(description = "市名称")
    private String cityName;

    @Schema(description = "省ID")
    private Long provinceId;

    @Schema(description = "省名称")
    private String provinceName;

    @Schema(description = "收货详细地址")
    private String addr;

    @Schema(description = "退款原因")
    private String refundReason;

    public ProcessOrder(ProcessOrderDTO.CartCreateOrder dto,Long userId) {
        this.orderStatus = OrderStatusEnum.TO_BE_PAID.getCode();
        this.userId = userId;
        this.phone = dto.getPhone();
        this.contactPerson = dto.getContactPerson();
        this.provinceId = dto.getProvinceId();
        this.provinceName = dto.getProvinceName();
        this.areaId = dto.getAreaId();
        this.areaName = dto.getAreaName();
        this.cityId = dto.getCityId();
        this.cityName = dto.getCityName();
        this.addr = dto.getAddr();
    }

    public ProcessOrder initItemParam(ProcessOrderDTO.Cart cart,String name, String image) {
        this.orderType = cart.getType();
        this.itemName = name;
        this.itemImage = image;
        this.remark = cart.getRemark();
        return this;
    }

}
